﻿[
{
    "name": "User Details",
    "desc": "Gets the user name. Also gets and sets the image for the user's tile.",
    "source": function () {
        var userProfile = Windows.System.UserProfile.UserInformation;
        console.log({
            "Display name": userProfile.displayName,
            "First name ": userProfile.firstName,
            "Last name ": userProfile.lastName,
            "Location of User": userProfile.getUserImage(Windows.System.UserProfile.UserImageKind.smallBitmap).path
        });
    }
},
{
    "name": "Set user Image",
    "desc": "Sets the user image",
    "source": function () {
        var fileOpenPicker = new Windows.Storage.Pickers.FileOpenPicker();
        fileOpenPicker.fileTypeFilter.append(".png");
        fileOpenPicker.fileTypeFilter.append(".jpg")
        fileOpenPicker.fileTypeFilter.append(".jpeg")
        fileOpenPicker.commitButtonText = "Select PNG file";
        fileOpenPicker.pickSingleFileAsync().then(function (image) {
            Windows.System.UserProfile.UserInformation.setUserImageAsync(image).then(function () {
                console.log({ "User image set to": image.name });
            }, function () {
                console.error("Could not set user image to", image.name);
            });
        });
    }
},
{
    "name": "Lock Screen Image",
    "desc": "Get the user screen image",
    "source": function () {
        console.log("Location of Lock Screen Image", Windows.System.UserProfile.LockScreen.originalImageFile.path);
    }
},
{
    "name": "Set lock screen Image",
    "desc": "Sets the user image",
    "source": function () {
        var fileOpenPicker = new Windows.Storage.Pickers.FileOpenPicker();
        fileOpenPicker.fileTypeFilter.append(".png");
        fileOpenPicker.commitButtonText = "Select PNG file";
        fileOpenPicker.pickSingleFileAsync().then(function (image) {
            Windows.System.UserProfile.LockScreen.setImageFileAsync(image).then(function () {
                console.log("Lock screen image set to " + image.path);
            }, function () {
                console.log("Could not set lock image to " + image.path);
            });
        });
    }
}
]